{include file="public/header" /}
<style type="text/css">
/*强制table不换行*/
table td{word-break: keep-all;white-space:nowrap;}
table th{word-break: keep-all;white-space:nowrap;}
.tableWordVreakNone{
    white-space: normal !important;word-break: normal !important;
}
.laydate-icon {
    background: transparent !important;
}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>我的商品列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-10">
                    <form method="post" action="{:url('myGoodsList')}" id="searchForm" class="form-inline">
                        <label for="">商品名称</label>
                        <input type="text" name="goods_name" value="{$goods_name|default=''}" class="form-control">

                        <label for="">商品ID</label>
                        <input type="text" name="goods_id" value="{$goods_id|default=''}" class="form-control">

                        <label for="">上架时间：</label>
                        <input id="createTime" style="width: 220px;" class="form-control"
                                autocomplete="off" value="{$createTime|default=''}">
                        <input type="hidden" name="createTime" value="{$createTime|default=''}">

                        <br><br>
                        <label for="">积分区间：</label>
                        <input type="number" name="startPoint" value="{$startPoint|default=''}" class="form-control" style="width:100px;">
                        至 <input type="number" name="endPoint" value="{$endPoint|default=''}" class="form-control" style="width:100px;">

                        <button class="btn btn-success btn-sm" type="submit" style="margin-bottom:0;margin-left:4px"><i class="fa fa-filter"></i> 筛选</button>
                        <a class="btn btn-primary btn-sm"  style="margin-bottom:0" href="{:url('myGoodsList')}"><i class="fa fa-filter"></i> 重置</a>
                    </form>
                    </div>
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <div style="overflow-x:scroll;width:100%;">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                                <th>ID</th>
                                <th>商品名</th>
                                <th>图片</th>
                                <th>兑换商品所需积分</th>
                                <th>上架时间</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="list-content">
                            {foreach $list as $vo}
                                <tr class="long-td">
                                    <td>{$vo.goods_id}</td>
                                    <td class="tableWordVreakNone" style="width:20%;">{$vo.goods_name}</td>
                                    <td>
                                        <div class="layer-photos-demo">
                                            <img src="{$vo.goods_img}" style="width:40px;">
                                        </div>
                                    </td>
                                    <td>{$vo.point}</td>
                                    <td>{$vo.create_time}</td>
                                    <td>
                                        {if $vo.is_sale == config('enum.isSale.valid.value')}
                                            <span class="label label-info">已上架</span>
                                        {else /}
                                            <span class="label label-danger">已下架</span>
                                        {/if}
                                    </td>
                                    <td>
                                        <a href="{:url('editMyGoods',['id'=>$vo['id']])}" class="btn btn-primary btn-xs">
                                            <i class="fa fa-edit"></i> 编辑</a>&nbsp;&nbsp;
                                    </td>
                                </tr>
                            {/foreach}
                        </tbody>
                    </table>
                    </div>
                    <div id="laypage"></div>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

{include file="public/footer" /}
<script type="text/javascript" src="/static/admin/js/laypage.js"></script>
<script type="text/javascript">
layer.photos({
  photos: '.layer-photos-demo'
//  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
});

layui.use('laydate', function(){
    var laydate = layui.laydate;

    // 年月范围
    laydate.render({
      elem: "#createTime",
      type: 'date',
      range: true,
        done: function(value, date){
          $("input[name='createTime']").val(value);
        }
    });

});

layui.use(['laypage', 'layer'], function(){
  var laypage = layui.laypage
  ,layer = layui.layer;

  //完整功能
  laypage.render({
    elem: 'laypage'
    ,count: '{$list->total()}' // 总数据条数
    ,curr: '{$list->currentPage()}' // 当前第几页
    ,limit: '{$list->listRows()}'   // 每页显示条数
    ,layout: ['count', 'prev', 'page', 'next', 'refresh', 'skip']
    ,jump: function(obj, first){
      //首次不执行
      if(!first){
            $("#searchForm").attr('action', '{:url("myGoodsList")}?page='+obj.curr);
          $("#searchForm").submit();
      }
    }
  });
});

//function addMyGoods(goodsId) {
//	layer.confirm('确认要添加到我的商品吗？', {icon: 3}, function(index){
//        window.location.href="{:url('addMyGoods')}?goodsId="+goodsId
//	});
//}
</script>

</body>
</html>